//
//  LawProblemViewController.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/1/19.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "LawProblemViewController.h"
#import "LawProblemView.h"
#import "souSuoViewController.h"
@interface LawProblemViewController ()
@property(nonatomic,strong)LawProblemView *aView;

@end

@implementation LawProblemViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"法律问答";
    UIBarButtonItem *pulishButton=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"搜索"] style:UIBarButtonItemStylePlain target:self action:@selector(souSuo)];
    [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:pulishButton,nil]];

    
    _aView=[LawProblemView new];
    [self.view addSubview:_aView];
    [_aView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    _aView.page=@1;
    _aView.dataArr=[NSMutableArray arrayWithCapacity:0];
    _aView.viewController=self;
    [self loginView];
}
-(void)souSuo{
    souSuoViewController *souSuo=[[souSuoViewController alloc] init];
    souSuo.abc=4;
    [ZQTools pushNextViewController:self  andRootController:souSuo];
}
-(void)loginView{
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"ct_id", nil];
    [ZQTools AFNPostDataUrl:@"/api/index/case_type" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        NSMutableArray *tableArr=[NSMutableArray arrayWithCapacity:0];
        NSArray *typeArr=responseObject;
        NSDictionary *typeDic=[NSDictionary dictionaryWithObjectsAndKeys:@"全部",@"ct_name",@"0",@"ct_id", nil];
        [tableArr addObject:typeDic];
        for (int i=0; i<typeArr.count; i++) {
            [tableArr addObject:typeArr[i]];
        }
        _aView.titleArr=[NSArray arrayWithArray:tableArr];
        [self loadDate];
    } anderrorBlock:nil];
}
-(void)loadDate{
    NSDictionary *typeDic=_aView.titleArr[0];
    NSNumber *nt_id=[typeDic objectForKey:@"ct_id"];
    NSString *news_nt_id=[NSString stringWithFormat:@"%@",nt_id];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",_aView.page],@"page",news_nt_id,@"ct_id",@"10",@"pagesize", nil];
    [ZQTools AFNPostDataUrl:@"user/Question/question_list" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        
        NSArray *typeArr=responseObject;
        _aView.dataArr=[NSMutableArray arrayWithArray:typeArr];
        [_aView creatView];
    } anderrorBlock:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
